<!doctype html>
<html ng-app="open_manage">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="icon" href="../img/config.png">
    <!-- styles -->
    <link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css">
    <link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css">
    <link rel="stylesheet" type="text/css" href="../styles/common-style.css">
    <link rel="stylesheet" type="text/css" href="../vendor/select2/select2.min.css">
    <title>开放平台</title>
</head>

<body>

<apollonav></apollonav>


<div class="container-fluid" ng-controller="OpenManageController">
    <div class="col-md-10 col-md-offset-1 panel">

        <section class="panel-body" ng-show="isRootUser">
            <!--project admin-->
            <section class="row">
                <h5>创建第三方应用
                    <small>
                        (说明: 第三方应用可以通过Apollo开放平台来对配置进行管理)
                    </small>
                </h5>
                <hr>
                <form class="form-horizontal">
                    <div class="form-group" valdr-form-group>
                        <label class="col-sm-2 control-label">
                            <apollorequiredfield></apollorequiredfield>
                            第三方应用ID</label>
                        <div class="col-sm-3">
                            <input type="text" class="form-control" ng-model="consumer.appId">
                            <small>(创建前请先查询第三方应用是否已经申请过)</small>
                        </div>
                        <div class="col-sm-1">
                            <button class="btn btn-info" ng-click="getTokenByAppId()">查询</button>
                        </div>
                        <div class="col-sm-6">
                            <h4 style="color: red"
                                ng-show="consumerToken"
                                ng-bind="'Token: ' + consumerToken.token"></h4>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">
                            <apollorequiredfield></apollorequiredfield>
                            部门</label>
                        <div class="col-sm-3">
                            <select id="organization">
                                <option></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" valdr-form-group>
                        <label class="col-sm-2 control-label">
                            <apollorequiredfield></apollorequiredfield>
                            第三方应用名称</label>
                        <div class="col-sm-3">
                            <input type="text" class="form-control" ng-model="consumer.name">
                            <small>(建议格式 xx-yy-zz 例:apollo-server)</small>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">
                            <apollorequiredfield></apollorequiredfield>
                            项目负责人</label>
                        <div class="col-sm-6 J_ownerSelectorPanel">
                            <apollouserselector apollo-id="'ownerSelector'"></apollouserselector>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-9">
                            <button type="submit" class="btn btn-primary"
                                    ng-disabled="submitBtnDisabled"
                                    ng-click="createConsumer()">
                                创建
                            </button>
                        </div>
                    </div>
                </form>
            </section>

            <section class="row">
                <h5>赋权
                    <small>
                        (Namespace级别权限包括: 修改、发布Namespace。应用级别权限包括: 创建Namespace、修改或发布应用下任何Namespace)
                    </small>
                </h5>
                <hr>
                <form class="form-horizontal" ng-submit="assignRoleToConsumer()">

                    <div class="form-group" valdr-form-group>
                        <label class="col-sm-2 control-label">
                            <apollorequiredfield></apollorequiredfield>
                            token</label>
                        <div class="col-sm-5">
                            <input type="text" class="form-control" ng-model="consumerRole.token" required>
                        </div>
                    </div>
                    <div class="form-group" valdr-form-group>
                        <label class="col-sm-2 control-label">
                            <apollorequiredfield></apollorequiredfield>
                            被管理的AppId</label>
                        <div class="col-sm-3">
                            <input type="text" class="form-control" ng-model="consumerRole.appId" required>
                        </div>
                    </div>
                    <div class="form-group" valdr-form-group>
                        <label class="col-sm-2 control-label">
                            被管理的Namespace</label>
                        <div class="col-sm-3">
                            <input type="text" class="form-control" ng-model="consumerRole.namespaceName">
                            <small>(非properties类型的namespace请加上类型后缀，例如apollo.xml)</small>
                        </div>
                    </div>
                    <div class="form-group" valdr-form-group>
                        <label class="col-sm-2 control-label">
                            授权类型
                        </label>
                        <div class="col-sm-3">
                            <label class="radio-inline">
                                <input type="radio" name="inlineRadioOptions"  ng-value="'NamespaceRole'" ng-model="consumerRole.type">
                                Namespace
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="inlineRadioOptions"  ng-value="'AppRole'" ng-model="consumerRole.type">
                                App
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-9">
                            <button type="submit" class="btn btn-primary"
                                    ng-disabled="submitBtnDisabled">
                                提交
                            </button>
                        </div>
                    </div>
                </form>

            </section>

        </section>

        <section class="panel-body text-center" ng-if="!isRootUser">
            <h4>当前页面只对Apollo管理员开放</h4>
        </section>

    </div>
</div>

<div ng-include="'../views/common/footer.html'"></div>

<!-- jquery.js -->
<script src="../vendor/jquery.min.js" type="text/javascript"></script>

<!--angular-->
<script src="../vendor/angular/angular.min.js"></script>
<script src="../vendor/angular/angular-route.min.js"></script>
<script src="../vendor/angular/angular-resource.min.js"></script>
<script src="../vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="../vendor/angular/loading-bar.min.js"></script>

<!--valdr-->
<script src="../vendor/valdr/valdr.min.js" type="text/javascript"></script>
<script src="../vendor/valdr/valdr-message.min.js" type="text/javascript"></script>

<!-- bootstrap.js -->
<script src="../vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<!--nicescroll-->
<script src="../vendor/jquery.nicescroll.min.js"></script>
<script src="../vendor/lodash.min.js"></script>

<script src="../vendor/select2/select2.min.js" type="text/javascript"></script>
<!--biz-->
<!--must import-->
<script type="application/javascript" src="../scripts/app.js"></script>
<script type="application/javascript" src="../scripts/services/AppService.js"></script>
<script type="application/javascript" src="../scripts/services/EnvService.js"></script>
<script type="application/javascript" src="../scripts/services/UserService.js"></script>
<script type="application/javascript" src="../scripts/services/CommonService.js"></script>
<script type="application/javascript" src="../scripts/services/PermissionService.js"></script>
<script type="application/javascript" src="../scripts/services/OrganizationService.js"></script>
<script type="application/javascript" src="../scripts/services/ConsumerService.js"></script>

<script type="application/javascript" src="../scripts/AppUtils.js"></script>

<script type="application/javascript" src="../scripts/PageCommon.js"></script>
<script type="application/javascript" src="../scripts/directive/directive.js"></script>
<script type="application/javascript" src="../scripts/valdr.js"></script>

<script type="application/javascript" src="../scripts/controller/open/OpenManageController.js"></script>
</body>
</html>
